package com.mg.framework.tiled;

import java.util.Iterator;
import java.util.LinkedList;

public class ObjectGroup extends MapLayer {

	private LinkedList<MapObject> objects;

	public ObjectGroup(int layerWidth, int layerHeight) {
		super(layerWidth, layerHeight);
		this.objects = new LinkedList<MapObject>();
	}

	public void addObject(MapObject o) {
		objects.add(o);
		o.setObjectGroup(this);
	}

	public MapObject getMapObject(String name) {
		Iterator<MapObject> iterator = this.objects.iterator();
		while (iterator.hasNext()) {
			MapObject mapObject = iterator.next();
			if (mapObject.isMe(name)) {
				return mapObject;
			}
		}
		return null;
	}
}
